package com.cinc.mdm.modules.movementType.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cinc.mdm.constant.MdmConstant;
import com.cinc.mdm.modules.movementType.entity.MdmMovementType;
import com.cinc.mdm.modules.movementType.mapper.MdmMovementTypeMapper;
import com.cinc.mdm.modules.movementType.service.IMdmMovementTypeService;
import org.jeecg.common.util.oConvertUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: 移动类型
 * @Author: jeecg-boot
 * @Date: 2022-04-09
 * @Version: V1.0
 */
@Service
public class MdmMovementTypeServiceImpl extends ServiceImpl<MdmMovementTypeMapper, MdmMovementType> implements IMdmMovementTypeService {

    /**
     * 移动类型ID查询
     *
     * @return java.lang.String
     * @throws
     */
    @Override
    public String findIdByTypeNo(String typeNo) {
        LambdaQueryWrapper<MdmMovementType> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(MdmMovementType::getTypeNo, typeNo)
                .eq(MdmMovementType::getEnableFlag, MdmConstant.YES);
        List<MdmMovementType> mdmMovementTypeList = baseMapper.selectList(queryWrapper);

        return oConvertUtils.listIsEmpty(mdmMovementTypeList) ? null : mdmMovementTypeList.get(0).getId();
    }

    /**
     * 反向移动类型ID查询
     *
     * @param typeNo@return java.lang.String
     * @throws
     */
    @Override
    public String findReverseIdByTypeNo(String typeNo) {
        LambdaQueryWrapper<MdmMovementType> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(MdmMovementType::getTypeNo, typeNo)
                .eq(MdmMovementType::getEnableFlag, MdmConstant.YES);
        List<MdmMovementType> mdmMovementTypeList = baseMapper.selectList(queryWrapper);

        return oConvertUtils.listIsEmpty(mdmMovementTypeList) ? null : mdmMovementTypeList.get(0).getReverseId();
    }

}
